<?php
session_start();
require("include/connect.php");
$CID=$_SESSION['CID'];
$name=$_REQUEST['name'];
$area=$_REQUEST['area'];
$block=$_REQUEST['block'];
$jadda=$_REQUEST['jadda'];
$houseno=$_REQUEST['houseno'];
$landmark=$_REQUEST['landmark'];
$date = date('Y-m-d h:i:s');
$sql="update customer set area='$area',jadda='$jadda',block='$block',houseno='$houseno',delivery_direction='$landmark' where CustomerID=$CID";
$res=mysqli_query($con,$sql);


$pname=$_REQUEST['pname'];
$quantity=$_REQUEST['quantity'];

$sql="insert into orders (CustomerID,OrderTotalPrice,OrderDate,OrderStatus,CancelStatus,OrderComment) values ('$CID','$_SESSION[total_number]','$date','1','0','0')";
$res=mysqli_query($con,$sql);

$id = mysqli_insert_id($con);
$cartids = $_SESSION['cart'];

for($i=0;$i<count($cartids);$i++){
$cid=$_SESSION['cart']['id'];
$cqty = $_SESSION['cart']['qty'];
$sql="select Price,ProductCode from product where ProductID='$cid'";
$res=mysqli_query($con,$sql);
$myrow = mysql_fetch_array($res);
$ProductCode = $myrow['ProductCode'];
$price=$myrow['ProductCode'];

$sql="insert into cart(CartShopID,ProductID,ProductCode,ProductQty,Price) values('$id','$cid','$ProductCode','$cqty','$price')";
}


?>